|
|
|
|
|
|
|
Now add the code shown in Listing 5.47 to each of the error events and the cmdOK_Click events. |
|
|
|
|
|
|
|
|
Listing 5.47. Adding code for the Required and Conditional options. |
|
|
|
|
|
|
|
|
Private Sub cmdOK_Click()
'
If vtxInRange.CheckRange = True Then
vtxInRange.InRangeValidate
End If
'
If vtxCheckSize.CheckSize = True Then
vtxCheckSize.CheckSizeValidate
End If
'
If vtxConditional.CheckConditional = True Then
vtxConditional.ConditionalValidate _
"vtxConditional", "vtxUpper", vtxUpper.Text
End If
'
End Sub
Private Sub vtxConditional_ConditionalError(strMsg As Variant)
'
MsgBox strMsg
'
End Sub
Private Sub vtxRequired_RequiredError()
'
MsgBox " This is a required field!"
'
End Sub |
|
|
|
|
|
|
|
|
Notice the use of parameters when calling the ConditionalValidate method. You should also note that the ConditionalValidate method is the only method in this control that must be executed by the user. There is no normal event that forces a conditional input check across multiple data entry fields on a form. Now save and run the project. You should see error messages when you attempt to violate the data entry rules on these controls. |
|
|
|
|
|
|
|
|
Compiling and Registering the VText Control |
|
|
|
|
|
|
|
|
Now that you have coded, saved, and tested the VText control, you are ready to create an ActiveX control (or OCX) from the file. Select File | Make OCX from the main menu. You |
|
|
|
|
|